import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd

from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split

iris = load_iris()
# print(iris)


# # 数据集属性描述
# # 特征值是这朵花的长宽高之类，目标值是这朵花的种类

# print("特征值名称\n",iris.feature_names)
# print("特征值\n",iris.data)
# print("目标值名称\n",iris.target_names)
# print("目标值\n",iris["target"])
# print("数据集描述\n",iris.DESCR)

# 3.数据集可视化
iris_d = pd.DataFrame(data= iris.data, columns=["Sepal_Length", "Sepal_Width", "Petal_Length", "Petal_Width"])
iris_d["target"]=iris.target
# print(iris_d)

def iris_plot(data, col1, col2):
    sns.lmplot(x= col1, y= col2, data= data, hue= "target", fit_reg= False)
    plt.title("鸢尾花数据显示")
    plt.show()

# iris_plot(iris_d, "Sepal_Width", "Petal_Length")

# 4 数据集划分
x_train, x_test, y_train, y_test = train_test_split(iris.data, iris.target, test_size=0.2, random_state=22)
print("训练集特征值\n",x_train)
print("训练集目标值\n",y_train)
print("测试集特征值\n",x_test)
print("测试集目标值\n",y_test)
print("训练集目标值形状\n",y_train.shape)
print("测试集目标值形状\n",y_test.shape)